<?php /*a:4:{s:64:"D:\laragon\www\jiaqueshop\application\manage\view\goods_add.html";i:1598065140;s:59:"D:\laragon\www\jiaqueshop\application\manage\view\base.html";i:1596192950;s:68:"D:\laragon\www\jiaqueshop\application\manage\view\public_upload.html";i:1591401853;s:68:"D:\laragon\www\jiaqueshop\application\manage\view\public_editor.html";i:1540951044;}*/ ?>
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
	<meta name="renderer" content="webkit">
<title>后台管理系统</title>
<link rel="stylesheet" href="/static/public/awesome/css/font-awesome.min.css" />

<link rel="stylesheet" href="/static/public/layui/css/layui.css" />

<link rel="stylesheet" href="/static/public/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="/static/manage/css/style.css" />

	<link rel="stylesheet" href="/static/public/dist/zoomify.min.css">
	
<script src="/static/public/kindeditor/kindeditor-all.js"></script>
<script src="/static/public/kindeditor/lang/zh_CN.js"></script>
<script src="/static/public/ueditor/ueditor.config.js?t=<?php echo time();?>"></script>
<script src="/static/public/ueditor/ueditor.all.min.js"></script>
<script src="/static/public/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<body>
<?php if($is_auth): ?>

<script language="javascript" type="text/javascript" src="/static/public/My97DatePicker/WdatePicker.js"></script>
<div class="g-main">
    <div class="m-main-title">
        <div class="m-container-fluid">
            <a href="<?php echo url('index/welcome'); ?>"><i class="icon icon-home"></i>首页</a>
            <span class="icon-angle-right"></span>
            <span>商城</span>
            <span class="icon-angle-right"></span>
            <span>商品管理</span>
            <span class="icon-angle-right"></span>
            <span>商品管理</span>
            <span class="icon-angle-right"></span>
            <span><?php echo !empty($info) ? '编辑'  :  '添加'; ?>商品</span>
            <a class="u-flush"><i class="icon-repeat"></i></a>
        </div>
    </div>
    <div class="m-main-content">
        <div class="m-container">
            <div class="m-form">
                <form class="layui-form" id="j_form">
                    <table class="m-table">
                        <tbody>
                            <tr>
                                <th colspan="2">商品信息</th>
                            </tr>
                            <tr>
                                <td width="15%"><label for="goods_name">商品名称<em>*</em></label></td>
                                <td><input type="text" class="u-ipt u-ipt-longer" name="goods_name" id="goods_name" placeholder="请输入商品名称" value="<?php echo htmlentities($info['goods_name']); ?>" /></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="goods_sn">商品货号</label></td>
                                <td><input type="text" class="u-ipt u-ipt-long" name="goods_sn" id="goods_sn" placeholder="请输入商品货号" value="<?php echo htmlentities($info['goods_sn']); ?>" /></td>
                            </tr>
                            <tr>
                                <td><label for="">所属分类<em>*</em></label></td>
                                <td>
                                    <div class="lay-select m-select-def">
                                        <select name="category_id" lay-filter="category_id">
                                            <option value="0">请选择分类</option>
                                            <?php if(is_array($categories) || $categories instanceof \think\Collection || $categories instanceof \think\Paginator): if( count($categories)==0 ) : echo "" ;else: foreach($categories as $key=>$v): ?>
                                            <option value="<?php echo htmlentities($v['id']); ?>"<?php if(!$v['is_last']): ?> disabled<?php endif; if($info['category_id'] == $v['id']): ?> selected<?php endif; ?>><?php echo htmlentities(html_entity_decode($v['html'])); ?>|-<?php echo htmlentities($v['name']); ?></option>
                                            <?php endforeach; endif; else: echo "" ;endif; ?>
                                        </select>
                                    </div>
                                </td>
                            </tr>



                            <tr>
                                <td><label for="goods_type">商品品类</label></td>
                                <td>
                                    <div class="lay-select m-select-def">
                                        <select name="goods_type">
                                            <option value="1"<?php if($info['goods_type'] == 1): ?> selected<?php endif; ?>>实物</option>
                                            <option value="2"<?php if($info['goods_type'] == 2): ?> selected<?php endif; ?>>虚拟产品</option>
                                        </select>
                                    </div>
                                </td>
                            </tr>

                            <tr>
                                <td><label for="type">商品类型</label></td>
                                <td>
                                    <div class="lay-select m-select-def">
                                        <select name="type">
                                            <option value="1"<?php if($info['type'] == 1): ?> selected<?php endif; ?>>商城商品</option>
                                            <option value="2"<?php if($info['type'] == 2): ?> selected<?php endif; ?>>积分商品</option>
                                        </select>
                                    </div>
                                </td>
                            </tr>



                            <tr>
                                <td width="15%"><label for="goods_unit">商品单位</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="goods_unit" id="goods_unit" placeholder="请输入商品单位" value="<?php echo htmlentities((isset($info['goods_unit']) && ($info['goods_unit'] !== '')?$info['goods_unit']:'')); ?>" /></td>
                            </tr>
							<tr>
								<td width="15%"><label for="goods_weight">商品重量</label></td>
								<td><input type="text" class="u-ipt u-ipt-small" name="goods_weight" id="goods_weight" placeholder="请输入商品重量" value="<?php echo htmlentities((isset($info['goods_weight']) && ($info['goods_weight'] !== '')?$info['goods_weight']:0)); ?>" /><span>kg</span></td>
							</tr>
                            <tr>
                                <td width="15%"><label for="cost_price">成本价</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="cost_price" id="cost_price" placeholder="请输入成本价" value="<?php echo htmlentities((isset($info['cost_price']) && ($info['cost_price'] !== '')?$info['cost_price']:'0.00')); ?>" /><span>元</span></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="market_price">市场价</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="market_price" id="market_price" placeholder="请输入市场价" value="<?php echo htmlentities((isset($info['market_price']) && ($info['market_price'] !== '')?$info['market_price']:'0.00')); ?>" /><span>元</span></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="sale_price">销售价<em>*</em></label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="sale_price" id="sale_price" placeholder="请输入销售价" value="<?php echo htmlentities((isset($info['sale_price']) && ($info['sale_price'] !== '')?$info['sale_price']:'0.00')); ?>"/><span>元</span></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="give_points">赠送积分<em>*</em></label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="give_points" id="give_points" placeholder="请输入赠送的积分" value="<?php echo htmlentities((isset($info['give_points']) && ($info['give_points'] !== '')?$info['give_points']:'0')); ?>"<?php if($info && $info['goods_spec_format']): ?> readonly<?php endif; ?> /><span>积分，请填写具体赠送积分的数值，0 或不填则按照系统设置 》积分设置中的比例计算。</span></td>
                            </tr>

                            <tr>
                                <td width="15%"><label for="diy_sale_nums">自定义销量</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="diy_sale_nums" id="diy_sale_nums" placeholder="请输入自定义销量" value="<?php echo htmlentities((isset($info['diy_sale_nums']) && ($info['diy_sale_nums'] !== '')?$info['diy_sale_nums']:'0')); ?>" /></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="actual_sale_nums">实际销量</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="actual_sale_nums" id="actual_sale_nums" placeholder="请输入实际销量" value="<?php echo htmlentities((isset($info['actual_sale_nums']) && ($info['actual_sale_nums'] !== '')?$info['actual_sale_nums']:'0')); ?>" readonly /></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="goods_stock">总库存<em>*</em></label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="goods_stock" id="goods_stock" placeholder="请输入总库存" value="<?php echo htmlentities((isset($info['goods_stock']) && ($info['goods_stock'] !== '')?$info['goods_stock']:'0')); ?>"<?php if($info && $info['goods_spec_format']): ?> readonly<?php endif; ?> /></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="goods_stock_alarm">库存预警</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="goods_stock_alarm" id="goods_stock_alarm" placeholder="请输入库存预警数量" value="<?php echo htmlentities((isset($info['goods_stock_alarm']) && ($info['goods_stock_alarm'] !== '')?$info['goods_stock_alarm']:'0')); ?>" /><span>设置最低库存预警值。当库存低于预警值时商家中心商品列表页库存列红字提醒。0 为不预警。</span></td>
                            </tr>

							<?php if($distribution_info['commission_level'] >0): ?>
							<tr>
								<th colspan="<?php echo count($role); ?>">分销设置</th>
							</tr>
							<tr>
								<td width="15%"><label>是否参与分销</label></td>
								<td>
									<input type="radio" lay-filter="commission_charge_status" name="commission_charge_status" value="0" title="不参与" <?php if(isset($info['commission_charge_status']) && ($info['commission_charge_status'] == 0)): ?> checked<?php endif; ?> />
									<input type="radio" lay-filter="commission_charge_status" name="commission_charge_status" value="1" title="参与" <?php if(isset($info['commission_charge_status']) && ($info['commission_charge_status'] == 1)): ?> checked<?php endif; ?> />
								</td>
							</tr>
							<tr id="yjlx">
								<td width="15%"><label>佣金类型</label></td>
								<td>
									<input type="radio" lay-filter="commission_charge_type" name="commission_charge_type" value="0" title="默认系统" <?php if(isset($info['commission_charge_type']) && ($info['commission_charge_type'] == 0)): ?> checked<?php endif; ?> />
									<input type="radio" lay-filter="commission_charge_type" name="commission_charge_type" value="1" title="百分比" <?php if(isset($info['commission_charge_type']) && ($info['commission_charge_type'] == 1)): ?> checked<?php endif; ?> />
									<input type="radio" lay-filter="commission_charge_type"  name="commission_charge_type" value="2" title="固定金额" <?php if(isset($info['commission_charge_type']) && ($info['commission_charge_type'] == 2)): ?> checked<?php endif; ?> />
								</td>
							</tr>
							<?php if(is_array($role) || $role instanceof \think\Collection || $role instanceof \think\Paginator): $i = 0; $__LIST__ = $role;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?>
							<tr class="role">
								<td><label><?php echo htmlentities($v['name']); ?></label></td>
								<td>
									<span>一级佣金:</span>
									<input  type="text" name="commission_charge[<?php echo htmlentities($v['id']); ?>][commission_charge_first]" class="u-ipt u-ipt-def commission_charge_first"
										   value="<?php echo htmlentities((isset($info['commission_charge'][$v['id']]['commission_charge_first']) && ($info['commission_charge'][$v['id']]['commission_charge_first'] !== '')?$info['commission_charge'][$v['id']]['commission_charge_first']:0)); ?>"/><span class="danwei">元/%</span>
									<?php if($distribution_info['commission_level'] == 2): ?>
									<span>二级佣金:</span>
									<input type="text" name="commission_charge[<?php echo htmlentities($v['id']); ?>][commission_charge_second]" class="u-ipt u-ipt-def commission_charge_second"
										   value="<?php echo htmlentities((isset($info['commission_charge'][$v['id']]['commission_charge_second']) && ($info['commission_charge'][$v['id']]['commission_charge_second'] !== '')?$info['commission_charge'][$v['id']]['commission_charge_second']:0)); ?>"/><span class="danwei">元/%</span>
									<?php endif; ?>
								</td>

							</tr>
							<?php endforeach; endif; else: echo "" ;endif; endif; ?>
                            <tr>
                                <th colspan="2">商品模型</th>
                            </tr>
                            <tr>
                                <td rowspan="2"><label for="">商品模型</label></td>
                                <td>
                                    <div class="lay-select m-select-def">
                                        <select name="good_mods_id" lay-filter="good_mods_id">
                                            <option value="0">请选择商品模型</option>
                                            <?php if(is_array($goodMods) || $goodMods instanceof \think\Collection || $goodMods instanceof \think\Paginator): if( count($goodMods)==0 ) : echo "" ;else: foreach($goodMods as $key=>$v): ?>
                                            <option value="<?php echo htmlentities($v['id']); ?>"<?php if($info['good_mods_id'] == $v['id']): ?> selected<?php endif; ?>><?php echo htmlentities($v['name']); ?></option>
                                            <?php endforeach; endif; else: echo "" ;endif; ?>
                                        </select>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="m-good-specs">
                                    <table class="m-table">
                                        <thead>
                                        <tr>
                                            <th colspan="2">
                                                <h3>操作提示</h3>
                                                <p>1、双击规格值进行编辑操作（失去光标自动保存）。</p>
                                                <p>2、鼠标浮上图片时，可以进行预览。</p>
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody id="j_spec"></tbody>
                                    </table>
                                </td>
                            </tr>
                            <tr id="j_sku" class="dn">
                                <td><label for="">商品sku</label></td>
                                <td class="m-good-sku" id="j_good_sku"></td>
                            </tr>
                            <tr id="j_attr" class="dn">
                                <td><label for="">商品属性</label></td>
                                <td class="m-good-attrs">
                                    <table class="m-table">
                                        <tbody id="j_good_attr"></tbody>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <th colspan="2">商品图片</th>
                            </tr>
                            <tr>
                                <td><label for="">商品缩略图</label></td>
                                <td>
                                    <button type="button" class="layui-btn u-upload-pic" data-name="goods_thumb_id"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                                    <div class="m-pic">
                                        <ul>
                                            <?php echo attach_html($info['goods_thumb_id'], 'goods_thumb_id'); ?>
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <th colspan="2">商品图片</th>
                            </tr>
                            <tr>
                                <td><label for="">商品缩略图</label></td>
                                <td>
                                    <button type="button" class="layui-btn u-upload-pic" data-name="goods_thumb_id"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                                    <div class="m-pic">
                                        <ul>
                                            <?php echo attach_html($info['goods_thumb_id'], 'goods_thumb_id'); ?>
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td><label for="">商品相册</label></td>
                                <td>
                                    <button type="button" class="layui-btn u-upload-pics" data-name="goods_album"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                                    <div class="m-pics">
                                        <ul>
                                            <?php echo attach_html($info['goods_album'], 'goods_album', 'pics'); ?>
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td><label for="goods_video">商品视频</label></td>
                                <td>
                                    <button type="button" class="layui-btn u-upload-file" data-name="goods_video"><i class="layui-icon">&#xe67c;</i>上传视频</button>
                                    <div class="m-files">
                                        <ul class="m-jquery-sorted">
                                            <?php echo attach_html($info['goods_video'], 'goods_video', 'file'); ?>
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td><label for="goods_keywords">商品关键词</label></td>
                                <td><input type="text" class="u-ipt u-ipt-long" name="goods_keywords" id="goods_keywords" placeholder="请输入商品关键词" value="<?php echo htmlentities($info['goods_keywords']); ?>" /></td>
                            </tr>
                            <tr>
                                <td><label for="goods_intro">商品简介</label></td>
                                <td><div class="m-textarea"><textarea name="goods_intro" class="u-tarea" id="goods_intro" placeholder="请输入商品简介"><?php echo htmlentities($info['goods_intro']); ?></textarea></div></td>
                            </tr>
							
<!--							<tr>-->
<!--                                <td colspan="2"><label for="">产品参数<em>*</em></label></td>-->
<!--                            </tr>-->
<!--                            <tr  id="a_table">-->
<!--                                <td><a href="javascript:;" title="添加参数" class="u-plus" id="a"><i class="icon-plus">添加参数</i></a></td>-->
<!--                                <td class="canshu"></td>-->
<!--                            </tr>-->
							
                            <tr>
                                <th colspan="2">商品详情</th>
                            </tr>
                            <tr>
                                <td colspan="2"><label for="">商品详情<em>*</em></label></td>
                            </tr>
                            <tr>
                                <td colspan="2">
<!--                                <textarea name="goods_detail" style="width:100%;height:300px;visibility:hidden;"><?php echo htmlentities($info['goods_detail']); ?></textarea>-->
                                <textarea name="goods_detail" id="goods" style="width:100%;height:300px;" ><?php echo htmlentities($info['goods_detail']); ?></textarea>
                               </td>
                            </tr>
                            <tr>
                                <th colspan="2">其他信息</th>
                            </tr>
                            <tr>
                                <td><label for="">是否上架</label></td>
                                <td><div class="lay-checked"><input type="checkbox" name="is_sale" value="1" title="是" lay-skin="primary"<?php echo !empty($info['is_sale']) ? ' checked'  :  ''; ?> /></div></td>
                            </tr>
                            <tr>
                                <td><label for="">是否新品</label></td>
                                <td><div class="lay-checked"><input type="checkbox" name="is_latest" value="1" title="是" lay-skin="primary"<?php echo !empty($info['is_latest']) ? ' checked'  :  ''; ?> /></div></td>
                            </tr>
                            <tr>
                                <td><label for="">是否热卖</label></td>
                                <td><div class="lay-checked"><input type="checkbox" name="is_hot_sale" value="1" title="是" lay-skin="primary"<?php echo !empty($info['is_hot_sale']) ? ' checked'  :  ''; ?> /></div></td>
                            </tr>
                            <tr>
                                <td><label for="">是否推荐</label></td>
                                <td><div class="lay-checked"><input type="checkbox" name="is_recommand" value="1" title="是" lay-skin="primary"<?php echo !empty($info['is_recommand']) ? ' checked'  :  ''; ?> /></div></td>
                            </tr>
                            <tr>
                                <td><label for="">页面是否显示库存</label></td>
                                <td><div class="lay-checked"><input type="checkbox" name="is_stock_visible" value="1" title="是" lay-skin="primary"<?php echo !empty($info['is_stock_visible']) ? ' checked'  :  ''; ?> /></div></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="max_purchase_nums">每人限购</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="max_purchase_nums" id="max_purchase_nums" placeholder="请输入每人限购数量" value="<?php echo htmlentities((isset($info['max_purchase_nums']) && ($info['max_purchase_nums'] !== '')?$info['max_purchase_nums']:'0')); ?>" /><span>0 为不限制</span></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="min_purchase_nums">最少购买数量</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="min_purchase_nums" id="min_purchase_nums" placeholder="请输入最少购买数量" value="<?php echo htmlentities((isset($info['min_purchase_nums']) && ($info['min_purchase_nums'] !== '')?$info['min_purchase_nums']:'0')); ?>" /><span>0 为不限制</span></td>
                            </tr>
                            <tr>
                                <td><label for="list_order">排序</label></td>
                                <td><input type="text" class="u-ipt u-ipt-tiny" name="list_order" id="list_order" placeholder="请输入排序值" value="<?php echo htmlentities((isset($info['list_order']) && ($info['list_order'] !== '')?$info['list_order']:0)); ?>" /><span>值越大越排在前面</span></td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="m-form-btn"><input type="hidden" name="id" value="<?php echo htmlentities($info['id']); ?>"><button id="j_add_goods" class="u-btn">确定提交</button></div>
                    <textarea name="goods_spec_format" class="dn"></textarea>
                </form>
            </div>
        </div>
    </div>
</div>

<?php endif; ?>
<input type="hidden" name="action_uri" value="<?php echo url('action'); ?>" />

<input type="hidden" name="redirect_uri" value="<?php echo url('index'); ?>" />

<input type="hidden" name="region_uri" value="/manage/regions/regions" />
<script src="/static/public/js/jquery-1.10.2.js"></script>
<script src="/static/public/js/maniac.ui.js"></script>
<script src="/static/public/layui/layui.js" charset="utf-8"></script>
<script src="/static/public/js/aes.js"></script>
<script src="/static/public/js/mode-ecb-min.js"></script>
<script src="/static/public/js/utils.js"></script>
<script src="/static/public/js/dialog.js"></script>
<script src="/static/manage/js/form.js"></script>
<script src="/static/manage/js/js.js"></script>
<script src="/static/public/js/app.js"></script>
<script src="/static/public/js/encrypt.js"></script>
<script src="/static/public/dist/zoomify.min.js"></script>
<script type="text/javascript">
    $('.fdzoom').zoomify();
</script>

<script>
var aesKey = '<?php echo htmlentities($encrypt_key); ?>';
    $(function(){
        layui.use('layer', function(){
            var user_exists = parseInt('<?php echo !empty($user_exists) ? 1  :  0; ?>');
            var user_forbidden = parseInt('<?php echo !empty($user_forbidden) ? 1  :  0; ?>');
            var quit_force = parseInt('<?php echo !empty($quit_force) ? 1  :  0; ?>');
            var is_auth    = parseInt('<?php echo !empty($is_auth) ? 1  :  0; ?>');
            
            if (user_exists) {
                dialog.error('您所登录的用户已被删除', function(){
                	top.location.href = '/manage';
                    return false;
                });
            }
            
            if (user_forbidden) {
                dialog.error('您的账户已被禁用', function(){
                	top.location.href = '/manage';
                    return false;
                });
            }

            if (quit_force) {
                dialog.error('同一账户同一时间只能一人在线', function(){
                	top.location.href = '/manage';
                    return false;
                });
            }
            
            if (!is_auth) {
                dialog.error('您没有权限执行此操作', function(){
                    window.location.href = history.go(-1);
                    return false;
                });
            }
        });
    })
</script>

<script src="/static/public/js/jquery-ui.min.js"></script>
<script>

    /**

     * 上传图片

     * @param  {object}  uploader upload 对象

     * @param  {string}  ele      容器选择器

     * @param  {boolean} multiple 是否允许多图上传

     */

    function upload_pic(uploader, ele, multiple)

    {

        var signature = setSign();

        uploader.render({

            elem: ele,

            field: 'imgFile',

            multiple: multiple,

            url: '<?php echo url("/manage/upload/upload", ["path" => session("userid", "", session_prefix()), "type" => "image", "module" => request()->module() ?: "addons"]); ?>',

            headers: {signature: signature},

            done: function(ret){

                var index = dialog.loading();

                if (ret.status == 0) {

                    var name = $(this.item).attr('data-name');

                    // 上传完毕回调

                    if (multiple) {

                        // 上传多图
                        $(this.item).parent().find('.m-pics ul').append('<li><img src="' + ret.data.attach_uri + '" alt="" /><input type="hidden" name="' + name + '[desc][]" value="' + ret.data.id + '" /><a class="u-item"><i class="icon icon-remove"></i></a><input type="hidden" name="' + name + '[value][]" value="' + ret.data.id + '" /></li>');
                    } else {

                        // 上传单图

                        $(this.item).parent().find('.m-pic ul').html('<li><img src="' + ret.data.attach_uri + '" alt="" /><a class="u-item"><i class="icon icon-remove"></i></a><input type="hidden" name="' + name + '" value="' + ret.data.id + '" /></li>');

                    }

                    layer.close(index);

                } else {

                    dialog.error(ret.message);

                    layer.close(index);
                }
            }
        })
    }


    /**
     * 上传图片
     * @param  {object}  uploader upload 对象
     * @param  {string}  ele      容器选择器
     * @param  {boolean} multiple 是否允许多图上传
     */
    function sxupload_pic(uploader, ele, multiple)
    {
        var signature = setSign();
        uploader.render({
            elem: ele,
            field: 'imgFile',
            multiple: multiple,
            url: '<?php echo url("api/v1/upload", ["path" => session("userid", "", session_prefix()), "type" => "image", "module" => request()->module() ?: "addons"]); ?>',
            headers: {signature: signature},
            done: function(ret){
                var index = dialog.loading();
                if (ret.status == 0) {
                    var name = $(this.item).attr('data-name');
                    // 上传完毕回调
                    if (multiple) {
                        // 上传多图
                        $(this.item).parent().find('.m-pics ul').append('<li><img src="' + ret.data.attach_uri + '" alt="" /><a class="u-item"><i class="icon icon-remove"></i></a><input type="hidden" name="' + name + '[value][]" value="' + ret.data.id + '" /></li>');
                    } else {
                        // 上传单图
                        $(this.item).parent().find('.m-pic ul').html('<li><img src="' + ret.data.attach_uri + '" alt="" /><a class="u-item"><i class="icon icon-remove"></i></a><input type="hidden" name="' + name + '" value="' + ret.data.id + '" /></li>');
                    }
                    layer.close(index);
                } else {
                    dialog.error(ret.message);

                    layer.close(index);
                }

            }

        })

    }



    /**

     * 上传附件

     * @param  {object}  uploader upload 对象

     * @param  {string}  ele      容器选择器

     */

    function upload_file(uploader, ele)

    {

        uploader.render({

            elem: ele,

            field: 'imgFile',

            accept: 'file',

            url: '<?php echo url("manage/upload/filemanager", ["path" => session("userid", "", session_prefix()), "type" => "file", "module" => request()->module() ?: "addons"]); ?>',

            done: function(ret){

                var index = dialog.loading();

                if (ret.status == 0) {

                    var name = $(this.item).attr('data-name');

                    // 上传完毕回调

                    $(this.item).parent().find('.m-files ul').append('<li><i class="icon-paper-clip"></i><input type="text" name="'+name+'[name][]" value="' + ret.data.title + '" /><a data-md5-file="' + ret.data.md5_file + '" data-id="' + ret.data.id + '" class="u-download">下载</a><a class="u-item" data-id="' + ret.data.id + '">删除</a><input type="hidden" name="' + name + '[value][]" value="' + ret.data.id + '" /></li>');

                    $(this.item).parent().find('.m-files').show();

                    layer.close(index);

                } else {

                	

                    dialog.error(ret.message);



                    layer.close(index);

                }

            }

        })

    }



    layui.use(['upload'], function(ele, multiple){

        // 得到 upload 对象

        var upload = layui.upload;

        // 上传单图

        upload_pic(upload, '.u-upload-pic', false);

        // 上传多图

        upload_pic(upload, '.u-upload-pics', true);

        // 上传附件

        upload_file(upload, '.u-upload-file');

        //双喜
        sxupload_pic(upload, '.sxu-upload-pic', false);
        sxupload_pic(upload, '.sxu-upload-pics', true);
    });

</script>
<script>
    var uploadJson = '<?php echo url("api/v1/upload", ["path" => session("userid", "", session_prefix()), "module" => request()->module() ?: "addons"]); ?>';
    var fileManagerJson = '<?php echo url("api/v1/filemanager", ["sub_path" => session("userid", "", session_prefix()), "module" => request()->module() ?: "addons"]); ?>';
</script>
<script>
var good_mods_id      = '<?php echo htmlentities($info['good_mods_id']); ?>';
var goods_spec_format = eval('<?php echo !empty($info['goods_spec_format']) ? html_entity_decode($info['goods_spec_format'])  :  "[]"; ?>');
var goods_sku         = eval('<?php echo !empty($sku) ? html_entity_decode($sku)  :  "[]"; ?>');
var goods_attr        = eval('<?php echo !empty($attr) ? html_entity_decode($attr)  :  "[]"; ?>');
var upload_uri        = '<?php echo url("api/v1/upload", ["path" => session("userid", "", session_prefix()), "type" => "image", "module" => request()->module() ?: "addons"]); ?>';
var upload_btn        = '/static/manage/images/goods_sku_add.png';
var uri               = $('input[name="action_uri"]').val();
//KindEditor.ready(function(K) {
//    var editor = K.create('textarea[name="goods_detail"]', {
//		allowFileManager: true,
//        uploadJson: uploadJson,
//        fileManagerJson: fileManagerJson,
//        afterBlur: function () {
//            this.sync();
//        }
//	});
//});

UE.getEditor('goods');

//参数添加
var arr=<?php echo json_encode($info['parameter_list']); ?>;

html="";
var kindex = 0
for (var i=0;i<arr.length;i++) {
    kindex++
    html+="<span style='display:block;margin-bottom: 5px;'>" +
        "<input type=\"text\" class=\"u-ipt u-ipt-long\" name=\"parameter["+i+"][name]\" value=\""+arr[i]['name']+"\">" +
        "<input type=\"text\" class=\"u-ipt u-ipt-long\" style='margin: 0 5px' name=\"parameter["+i+"][value]\" value=\""+arr[i]['value']+"\">" +
        "<a href=\"javascript:;\" title=\"删除\" class=\"u-inside-del\" data-id=\""+i+"\"><i class=\"icon-trash\"></i></a>" +
        "</span>"
}

$(".canshu").html(html);

// console.log(html)
//各种基于事件的操作，下面会有进一步介绍
$("#a").click(function(){
    kindex++
    var form_html="";

    form_html="<span style='display:block;margin-bottom: 5px;'>" +
        "<input type=\"text\" class=\"u-ipt u-ipt-long\" name=\"parameter["+kindex+"][name]\" value=\"\">" +
        "<input type=\"text\" class=\"u-ipt u-ipt-long\" style='margin: 0 5px' name=\"parameter["+kindex+"][value]\" value=\"\">" +
        "<a href=\"javascript:;\" title=\"删除\" class=\"u-inside-del\" data-id=\""+kindex+"\"><i class=\"icon-trash\"></i></a>" +
        "</span>"
    $(".canshu").append(form_html);
});

//参数删除
$("#a_table").on("click",".u-inside-del",function(){
    var id=$(this).attr("data-id");
    var obj=$(this);
    if(id == kindex){
        kindex--
    }

    obj.parent().remove();
});

</script>

<script>
    $(function () {
        var keyValue;
        keyValue = $("input[name='commission_charge_status']:checked").val();
        keyValue1 = $("input[name='commission_charge_type']:checked").val();

        if (keyValue == 0) {
            $("#yjlx").hide();
            $(".role").hide();
        }
        if (keyValue == 1) {
            $("#yjlx").show();
            $(".role").show();
        }

        if (keyValue1 == 0) {
            $('.commission_charge_first').attr("disabled",true);
            $('.commission_charge_second').attr("disabled",true);
        }
        if (keyValue1 == 1) {
            $('.commission_charge_first').attr("disabled",false);
            $('.commission_charge_second').attr("disabled",false);
        }
        if (keyValue1 == 2) {
            $('.commission_charge_first').attr("disabled",false);
            $('.commission_charge_second').attr("disabled",false);
        }
    })
    layui.use('form', function () {
        var form = layui.form;
        form.on('radio(commission_charge_status)', function (data) {
            if (data.value == 0) {
                $("#yjlx").hide();
                $(".role").hide();
            }
            if (data.value  == 1) {
                $("#yjlx").show();
                $(".role").show();
            }
            form.render();
        });
        form.on('radio(commission_charge_type)', function (data) {
            if (data.value == 0) {
                $('.commission_charge_first').attr("disabled",true);
                $('.commission_charge_second').attr("disabled",true);
            }
            if (data.value  == 1) {
                $('.commission_charge_first').attr("disabled",false);
                $('.commission_charge_second').attr("disabled",false);
            }
            if (data.value  == 2) {
                $('.commission_charge_first').attr("disabled",false);
                $('.commission_charge_second').attr("disabled",false);
            }
            form.render();
        });
    });
</script>


<script src="/static/public/js/good_add.js?t=<?php echo time();?>"></script>

</body>
</html>